# 7-6 个人数据脱敏【字符串】
def data_desensitization():
    n = int(input())
    if n <= 0:
        print('ERROR')
    else:
        info = []
        for _ in range(n):
            stu_info = input().split()
            student_id = stu_info[0]
            name = stu_info[1]
            phone = stu_info[2]

            # 处理学号
            final_id = student_id[:4] + '*' * 7 + student_id[11:]

            # 处理姓名
            final_name = name[0] + '*' + name[2:]

            # 处理电话号码
            final_phone = phone[:3] + '*' * 4 + phone[7:]

            info.append([final_id, final_name, final_phone])

        print(info)
data_desensitization()